const fs = require('fs')
const Router = require("koa-router")

let aipOcrClient = require('../utils/aipOcrClient.js')

let router = new Router()

router.all("/getimagetext", async (ctx, next) => {

  let files = ctx.request.files.file

  var image = fs.readFileSync(files.path).toString("base64");

  let text = await aipOcrClient.generalBasic(image, {
    recognize_granularity: 'small',
    vertexes_location: 'true',
    location: true
  })

  ctx.body = text
})

router.all("/test", async (ctx, next) => {

  ctx.body = {success: true}
  
})


module.exports = router
